<template>
    <div>

        <Row style="margin-top:20px">
            <Col span="19" class="table-form-input-select-col">
            <span class="alltitle"><router-link to="项目列表"> 项目列表</router-link>>版块管理</span>
            </Col>
        </Row>
        <Row class="fazhanlicheng" style="margin-top:20px;height:40px;padding-left:20px">
            <span class="title">版块管理</span>
        </Row>
        <Row class="fazhanlicheng" style="heigh:60px;">
            <Col class="inner-info2" offset="1">公司信息</Col>

            <Col class="inner-info2" offset="2">职位信息</Col>

            <Col class="inner-info2" offset="2">选择版块</Col>
            <Col span="2" style="margin-right:10px;">
            <Select class="time-picker" style="width:100%" v-model="qatype">
                <Option v-for="target in qatypelist" :value="target.name">{{target.name}}</Option>
            </Select>
            </Col>
            <Col class="inner-info2" offset="2">选择版块2</Col>
            <Col span="2" style="margin-right:10px;">
            <Select class="time-picker" style="width:100%" v-model="qatype2">
                <Option v-for="target in qatypelist" :value="target.name">{{target.name}}</Option>
            </Select>
            </Col>
            <Col class="inner-info2" offset="2">选择版块3</Col>
            <Col span="2" style="margin-right:10px;">
            <Select class="time-picker" style="width:100%" v-model="qatype3">
                <Option v-for="target in qatypelist" :value="target.name">{{target.name}}</Option>
            </Select>
            </Col>


        </Row>
        <Row class="add-new-progress" style="heigh:60px;background:#f5f7f9">
            <Button type="primary" style="width:100px" @click="handleCoInfo">确认保存</Button>
        </Row>

    </div>
</template>
<script>
import {
    formatDate
} from '@/js/date.js'
export default {
    data() {
            return {
                formValidate2: {

                },
                ruleValidate2: {

                },
                data: [],

                showDataModalObject: {},
                data2: {},
                showDataModalFlag: false,
                question: '',
                answer: '',
                qatype: '',
                qatype2: '',
                qatype3: '',
                qatypelist: [{name:"招聘流程"},{name:"宣讲行程"},{name:"Q&A"},{name:"VR360"},{name:"最新资讯"}],
                sort: ''
            }
        },
        methods: {
            addqatype() {
                this.$Modal.confirm({
                    render: (h) => {
                        return h('Input', {
                            props: {
                                value: this.value,
                                autofocus: true,
                                placeholder: '请输入类别'
                            },
                            on: {
                                input: (val) => {
                                    this.value = val;

                                }
                            }
                        })
                    },
                    onOk: () => {
                        var self = this
                        var poid = localStorage.pid;

                        $.ajax({
                            url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=qatypecreate&id=" + poid,
                            data: {
                                'name': this.value
                            },
                            type: "POST",
                            dataType: "json",
                            success: function(result) {
                                console.log(result);
                                if (result.code == 1) {
                                    self.$Message.success('添加成功！');
                                    self.qatypesearch();

                                } else {
                                    self.$Message.error('添加失败');
                                }
                            }
                        });

                    }
                })
            },
            removeData(index) {
                var self = this
                self.$Modal.confirm({
                    title: '确认删除？',
                    content: '',
                    onOk: () => {

                        var self = this;
                        self.$api.post('/api/v1/edit', self.data[index], function(result) {
                            self.data.splice(index, 1)
                            self.$Message.info(result.message)
                        })


                        $.ajax({
                            url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=qadel&id=" + self.data[index].id,

                            type: "POST",
                            dataType: "json",
                            success: function(data) {

                                console.log(data);

                            }
                        });
                    },
                    onCancel: () => {
                        this.$Message.info('取消删除');
                    }
                });

            },
            edit(index) {
                this.showDataModalFlag = true;
                this.data2 = this.data[index];

                console.log(this.data[index])
            },


            handleCoInfo() {

                var poid = localStorage.pid;
                var self = this
               // alert("abc")
                $.ajax({
                    url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=boardedit&id=" + poid,
                    data: {
                        board3: self.qatype,
                        board4: self.qatype2,
                        board5: self.qatype3,
                    },
                    type: "POST",
                    dataType: "json",
                    success: function(data) {
                        console.log(data);
                        self.$Message.success("保存成功！");
                        self.qalist();

                    }
                });
            },

            qatypesearch() {
                var self = this;
                var poid = localStorage.pid;
                $.ajax({
                    url: " https://evp.51job.com/51job/api/51miniadmin/back.php?action=qatypelist&id=" + poid,
                    type: "POST",
                    dataType: "json",
                    success: function(data) {
                        console.log(data);
                        self.qatypelist = data.data;


                    }
                });
            },
            qalist() {
                var self = this;
                var poid = localStorage.pid;

                $.ajax({
                    url: "https://evp.51job.com/51job/api/51miniadmin/back.php?action=boardone&id=" + poid,
                    type: "POST",
                    dataType: "json",
                    success: function(data) {
                        console.log(data);
                        self.qatype=data.data.board3;
                        self.qatype2=data.data.board4;
                        self.qatype3=data.data.board5;


                    }
                });
            },


        },
        created() {
            var self = this;
            var poid = localStorage.pid;
            //self.qatypesearch();
            self.qalist();
        }
}
</script>
<style scoped>
.innertitle {
    line-height: 30px;
    font-size: 14px;
    text-decoration: underline;
    color: #4B80FD;
    font-family: MicrosoftYaHei;
    cursor: pointer;
}

.fazhanlicheng {
    box-sizing: border-box;
    background: #fff;
    margin-bottom: 1px;
    padding: 0px;
}

.title {
    font-size: 14px;
    color: #333333;
    letter-spacing: 0;
    line-height: 40px;
    font-weight: bold;
}

.inner-info2 {
    float: left;
    line-height: 60px;
    font-size: 14px;
    color: #333;
    font-family: MicrosoftYaHei;
    margin-right: 10px;
}

.time-picker {
    margin-top: 15px;
}

.add-new-progress {
    box-sizing: border-box;
    background: #fff;
    padding: 0;
    text-align: center;
    color: #4B80FD;
    font-family: SourceHanSansCN-Normal;
    font-size: 14px;
    line-height: 60px;
    cursor: pointer;
}
</style>
